package simulator;

import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;

import javax.swing.JFrame;

public class DragFrame extends JFrame {
	private static final long serialVersionUID = 6806681322090492531L;
	private Point p = null;
	
	public DragFrame() {
		addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent e) {
				p = e.getPoint();
			}
		});
		
		addMouseMotionListener(new MouseMotionAdapter() {
			public void mouseDragged(MouseEvent e) {
				Point p1 = e.getPoint();
				Point p2 = getLocation(null);
				p2.x += p1.x - p.x;
				p2.y += p1.y - p.y;
				setLocation(p2);
			}
		});
	}
}

/*import java.awt.*; 
import javax.swing.*; 
import java.awt.event.*; 

public class DragFrame extends JFrame { 
private Point p = null; 

public static void main(String[] args) { 
DragFrame df = new DragFrame(); 
df.setUndecorated(true); 
df.setSize(400, 400); 
df.setVisible(true); 
} 

public DragFrame() { 
addMouseListener(new MouseAdapter() { 
public void mousePressed(MouseEvent e) { 
p = e.getPoint(); 
} 

public void mouseReleased(MouseEvent e) { 
} 
}); 
addMouseMotionListener(new MouseMotionAdapter() { 
public void mouseDragged(MouseEvent e) { 
Point p1 = e.getPoint(); 
Point p2 = getLocation(null); 
p2.x += p1.x - p.x; 
p2.y += p1.y - p.y; 
setLocation(p2); 
} 
}); 
}
}*/